Some minor improvements

Use Seq.append/List.append instead of Seq.collect id/List.collect id for
flattening collections