Cleaning up code and working on the save function