Avoid some possible NullPointerExceptions

 (using short circuit && correctly and adding forgotten 'else' keyword)