Optimization improvements to calling the `f` function

Gets rid of extra anonymous functions around `f`