Begin transactions and locking