Improved tk_purchase and tk_sale to fix potential errors.