Optimization. Fix function reference determining