fix delegate memory handling