Fix some array bugs