Code: Null checkes (#1216 and #1221)

Fixes #1216 and #1221.