Fix regressions wrt. function scope