Code cleanup, comments, misc fixes.