Finishes up Tran.

Cleans up a lot of the code, and fixes one or two small bugs that were stopping the test case from working.