add assertion to ensure locked bucket is the same as bucket modified.
fix a bug on deallocation