Fix various serialization problems