Changes to buy.php and download.php. Query fixes