Reduced amount of time files are opened, and fixed some syntax errors