added local() blocks to several functionals