Namespace reorganization

My other pull request was out of sync. Pardon the commit messages, as I wasn't sure that we agreed on a format for them yet.