replace some loops with standard algorithms
make it read from right to left
remove raw loops, use algorithms
set client_identity_ and log in Session::verify_client, more consistant logging