Fix some syntax and variable issues