Added support for per-function scope restrictions.