rename logic and fix output directories.