added missing namespaces, added \ for global functions

work in progress, not tested.