refactoring a bit to move some things into modules.