Modified script to preserve permissions.