Fix a potential NPE.
Improve sanitizing of the integer values.