Add null checks in constructor