Refactoring for serialization.