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