Refactor iteration functions to align with _.each

This separates object and array iteration into separate loops similar to _.each. This should give a performance boost and unify the style.