[PATCH 01/12] Cleanup: correctly handle upper bound of array