Fixes APLO-303: AssertionError: Use of object not allowed after it has been released.