Create directories before copying files. Rename some variables.