Tidy up.
Mak esure we wait until transaction is complete before unlocking.
Tidy up a little more.
Merge pull request #12 from noblesamurai/more_txn_safety

More transaction safety.