Fixed showing not permitted message if some one tryed to export the
stats.
finished function to write stats to xml
fixed the code I broke in the last commit (some really shitty commit