Finished the implementation of TRIV.

Rearranged the interface slightly, not finished yet.