Add -undo flag, fix nested dependency copying