Mostly done, some refactoring to do amongst other stuff