Rewrote most of the basic TVE functions.