Recommitted parts of bb8ef151e4676c16459bfac3287312f3c261d698
Removed flatten, flattenNZ, flattenNZcat, #983
Updated Octave tests, #983