more refactoring work, start work on module layer