Previously, a global logger was used, which would have given problems on a parallel run. Also split up the `setupdatadir()` function to improve code structure.