Refactoring, decoupling different parts