Fixed possible NullPointerException warnings