Null checks to prevent crashing with null Entity. Should fix #72