Some improvements to the conversion between types.