Removed unneeded variables. Checked for directories before making them to avoid warning.