Fix file modes and minor tweaks