Improve upload, catch errors, introduce copyTargetDir