Fixed a bug when a getter returned null

Improved exception handling