Late comment (I only just looked at this bit of code properly):  what's the reason for using weakrefs for the initialize and uninitialize functions?  What goes wrong with plain old strong references?