Multi-threading support: thread-local storage bulk connection management related flags + extract with_remapped_databases and related methods into a separate module