Fixed issues with encoding of null values
Removed code duplication in TypeConverter