Refactoring
a lot of it