working on flattening

added all_same to utils, made formatting changes, nothing major.