Fixing bug of assertion order in deallocation