fixed crash while instantiating generic-wrapped objects from external code, please review