Fixed Null pointer errors