Rough, heavy refactoring