Move tracking code back to the head