Cleaning up and documenting. Switch enumeration to use streams instead of arrays directly