Large refactoring - without tests :(