Use flatten instead of keys, as it behaves the same in all Ruby versions