Fixed syntax and variable naming conflicts