General improvements

Working on some of the todos, misc minor refactoring, better whitespace,
better comments, better use of conventions