Changed the way SQL queries were handled for improved security
Improved stats generation to reduce server load