Cleaned up version of annotation code

Needs the new version of TR unit testing code to correctly work, but the changes are separate.