Some changes to memory handler deallocation
Revert "Some changes to memory handler deallocation"

This reverts commit a3599a3b1046d7624ea94d4eba01e35da6cfba5f.