Various fixes for serialization.