@lattera Like, some of these functions feel like they might benefit from being methods on classes, which eliminates many of the passed around variables. A lot of the cleanup actions should probably be happening in context managers. The exceptions could probably be changed from a "catch, log and carry on" style into a "raise and forget" style. All of which, and more, would render the core, inner part of the code more succinct and readable.