Array refactor (again!)

Using macros to simplify this code a lot
Fixing up profiles a bit
Tidying up this file a bit
Adding gitignore
Fixing unnecessary extra imports; small enhancements here and there.