For issue #186 - make sure setRetainInstance does not crash