Refactored for dump to subdirectories.