Refactoring

I refactored a lot of things, see commit messages