Fixing syntax and optimizing.