Finished part of the saving code, still needs tweaks