Refactored serialization. base64 serialization now works again. TODO: binary serialization.