Isn't this first condition of the if not needed? It's just creating a dummy Matrix2D object and grabs the original data from pData anyways.

Could probably do this patch in a couple lines