Added null pointer checks on constructors.