Bug fixes

Fixing unknown variables and syntax errors.