acidburn, yeah, you're right. Fixed it below.
Thanks pipclown! As i suspected it doesn't disprove your finding, although percentages should now be more correct. Your script is slowly becoming a standard to check history data.

I think it already deserves it's own topic on the forum and sticky status. Good job!