clean up stats code