clean up code and add tracking insert api interface