Refactored all internal methods using kx.iterator.each()