Lots of bug fixes for stats

Also fixed the filename correction code and re-enabled stats in the
dropdown.