Bug fixes for purchase.php