Code: Null checks

Fixes #1064, #1078 and #1086.