Refactor

This is just formatting, and a few namespace changes. Sorry for the
megacommit (again)