Fixing some multidimensional array bugs