Fix problems with pointers causing objects not to persist beyond scope.