Flatten 2D arrays