Modifying transaction/semaphore system

The session now handles semaphores to ensure that transactions are
completed before a semaphore is acquired.