Many movings of local inside the actual functions. Add many missing local and remove -g(!). Fix namespacing of some parameters and functions, phases() in _scala was nice.