Fixing some syntax for IE and closure compiler
Fixing several bugs