Add utils.serialize.
Move private methods out of model definition.