Saving improvements

@cbott I'm still working on this, but I opened this PR to help track changes I make. No need to merge yet.
Also, is it okay if I move the clearing code to a separate function? It would make it a lot easier to keep track of (and the same code could also be used to set initial values when the program starts).