adding a whole pile of shit that I don't have the time to describe right now. Mostly tests and some refactoring