Minor fixes.
Adapted execution loop of client to achieve correct exit of program.