separate db/connection handling and bitmap operations more clearly