Update tracer

This is based on Srdjan's work so this pull request supersedes his.