Added ability to flatten or expand multi-dimensional arrays