Several fixes and support for optional fields in object types