fix js coffee errors in for loops, and binding this in callbacks