fix: rand() is never used, no need to call srand(..)
fix: harden flatten for illegal calls flatten(<ideal>)