Added the ui namespace and broke the main rendering function into a set of smaller functions. Reorganized the header code separating functions into rough groups that eventually will be in separate files.