Try to fix failed queries and dupliquates queries to the server

Hi, the second commit is probably not the right thing to do, i have found no other way to have one query per click.