Fix #1098: Some code uses $.each, some uses Array.prototype.forEach

This fixes #1098 by replacing every `$.each` in the core code with either `Array.forEach` for arrays or `CollectionUtils.forEach` for objects. The remaining `$.each` are only in jQuery.