Tweak namespace reattaching, and clean up.