bug and syntax fixes