Move factories into a separate module.