Code: Prevent from NullReferenceException (#1190)

Fixes #1190.