intermediate: heavy refactoring and restructuring