Rewrote serialization stuff