Some fixes discovered while porting to Ruby.
Make sure every session processes messages in both directions in the same order the messages arrive at the driver.