Implemented long polling

Long polling prevents the problem of interval poling where polls
collide when the response is longer than the interval. Required minimal
code changes.