A couple minor optimizations

Mainly, we know Z is reset because the malloc succeeded.  Also,
we don't have to copy the whole memblock, only the nonzero parts.