Clean code + fix error handling in copy
Merge branch 'bugfix_fmscopy' into upstream-4.0-stable