Fix bugs with array indexing, array detection