last working version (sqlite only) before big cleanup

trying to clean out cruft and get rid of IDTODbLogic once and for all.
this is the last (semi-) good version before the cleanup