Added checks for nulls in constructors