TR cleanup and reorganization of abbrevs and base type environment

For code review.

This PR is purely for refactoring and reorganization of code. I don't think it should conflict with any existing pull requests, but I wanted to make sure it wouldn't mess up anyone's rebasing. Also, some of the changes are stylistic (removing extra lines and making comments consistently double-semicolon, etc.) so let me know if anyone has any issues with those.