Fixed the query in report.php.
It took some 3-5 minutes to run on my computer,
but at least it did finish. I included the fix
at the bottom of the page.
Other changes are just style aspects.