g13: Move some code to a separate module.