check null because Nullable object must have a value

fixes #3642
Merge pull request #3650 from Mailaender/hackyai-nre

Attempt to fix some rare exceptions in HackyAI