Fixed two possible NullPointerException