Fix syntax errors and add additional file checks.