Move tracking code to header