working on factoring out query stuff from ui_state

this needs to be done to ease changing the design in a way such
that we are not holding sqlite statements open all the time.
keeping a sqlite statement open causes the shared db lock to
to stay allocated and prevents any other processes from being
able to acquire write locks.
finished factoring out query management from ui_state.

untested
sqlite db lock problem seems to have been fixed.

a write lock cannot be acquired when one or more shared (read)
locks are still open, thus in the previous design of ui_state
which kept select statements un-finalized until a new query
was about to run, no write locks could be acquired by any other
processes. this new design (committed in the previous commit)
finalizes all result queries as soon as possible.

re-enabling 'blocking' commit macro here because with the new
design no read lock should persist indefinitely.