bugfix in deallocate
Merge pull request #1868 from KonstantinMatskevich:umat_bugfix