Updated client to work with session id terminator
Improved readability, added comments