Small refactoring of the WeakPtr class.