Fix error serialization