Refactor to support ChocolateChipJS.

Many of the recent new features were not working with ChocolateChipJS
due to differences in handling dimensions, each iteration, etc.