Optimizing instantiation code structure