Replaced all $.each with .each to fix a bug with maximum call stack exceeded.