Revert "Revert "Improved copying of files""

This reverts commit 5ac20ac37a6f06cf568d32f22eda6bae03c6bb78.