Reformat and fix syntax errors