Removed unused db parameter from set-parameters
Reworked code that calls get-connection to conditionally call db-find-connection first so connections can be added (and closed!) correctly on-demand at any point in the workflow.