Cleaning up syntax errors in the generated JavaScript