Improved polling and db code (again)

For realsies this time