Big Refactoring

Big bunch of everything, please test in case the merge with master went wrong at some point.