clean up and add txt stats support