Fixed a bug and some syntactic errahs