clean up stats panel code