Misc refactoring of main module