Cleaned up CartesianIter code and genericized Take and Window.