Misc bug fixes, flags for serialization