Fixes to the permission of the folders, and checking that samba is killed before copying