Fix file permissions and line terminations