This was meant to be a more clever way to check for the appropriate run directory, both including extra process directories and cleaning up error messages. There were a bunch of typos in it. It seems to be working now.
Sorry @ewelina and @mcfayden !