Handle nulls in arrays
Fix invalid reference
Merge pull request #1007 from andrerod/generation

Handle NULL reference