EDITING: Saving

Various bug fixes, refactoring, and support for saving.