fix bugs in javascript and php client