Improved polling and db code

I hope