Updated to allow for more flexible directory targets.