Fix bug with sparce arrays.