added missing syntax and fixed a few minor bugs