Cleanup and unify serialization