Leak fixes

Fixes various bucket leaks and closely related issues. Included in purge-db4o-crypto.