Improved CSV output

Much more reliable, and has support for multi-dimensional arrays.

Also fixed all sorts of spacing and tabbing issues.