Move the logic from ModelWriter to ComplexType. Remove ModelWriter.