Make serialize and deserialize funcs separate funcs.

Since these functions do not directly interact with a  db transaction,
they can be their own function.  Pointed out by altoz and crew on IRC.