optimized function finalizeMagicCallNames