First trace functions and tests.
More trace tests and implementation.