fix purity client-server implementation

there were several bugs in the code that stopped the client-server
version from working, these are now resolved and it works as expected :)