Fix return values so error status resets
Fix file permissions