Crash-Bugfix

Prevents a NPE in some cases
Merge pull request #552 from Xfel/bugfix

Crash-Bugfix