Serialising/deserialising CAS

Hmm. Sorry about that formatting