File copy refactor

At last!
(i couldn't easily squash the merge commits though :( )