Restructured code to work with arrays
Merge branch 'master' into mono

* master:
  Restructured code to work with arrays