Namespace refactor, fixing a lot of correctness issues.