Added stricter testing for arrays sizes needed for allocation