restoring original domain size
changind len(arr.shape) -> arr.ndim; more comments (as per remarks from Dorota)