Fixed a bunch of serializations and rewrote safe file update