Clean/Rearranged the object tracking code