Moved stuff into the module, small refactoring