Fix memory leak, fix multy client support