move more shared code into a separate module