Memory leak in extension functions