small cleanups
directly use array length
fix each.js for new architecture