added null pointer fixes