add checking of non-null pointer in MxArray construction