make polling server code more robust