Fix NPE
Fix for #1070