More fixes to jQuery code