fixed issue with junk directories being left behind. cleaner simpler implementation now.