Fixed some array bugs