Fixed the generation of a null check before returning a value.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
Merge pull request #316 from ddobrev/master

Fixed the generation of a null check before returning a value