Fix race condition by reducing thread complexity

Thanks @jcoglan!
Fix some subtle timing issues discovered with soak tests
Add Rake file
Set logging when running rake
Collapse pointless Session / Client abstraction
Tidy up logging
Start to model as a state machine