Ensure that the target directory exists, with error checking turned on.

Fix issue #16.