massive refactoring (continue)