Lots of refactoring and cleaning up before making a first alpha