Optimize code for polls to avoid queries to be runned in loop
Merge pull request #1988 from xillibit/k30_bugs4

Optimize code for polls to avoid queries to be runned in loop