Redone a bunch of stuff related to the history (WATCH OUT THERE IS SOME
SERIOUS UNTESTED STUFF IN THAT COMMIT)