Fixed serialization code with intermediate coordinates.