Add hat tracking code from Duy. UNSURE HOW TO BUILD.