Possibly finished refactoring. Needs some testing