Fixed null pointer exceptions.