Some fixes to array indexing