Refactoring.  Fixing issues with output directories possibly not existing yet.