repair sluggish performance on purchase transaction

plus some bug fix