major refactoring towards decoupling