Move some cereal enc/decoding code to more appropriate places.