Modified the sync script to suit remote permissions better.