Added saving functions, a bunch of other stuff too