Prevent NPE
Fixes #1329