Fixed null pointer dereferences