[Caching] Adds some checks for overflow and valid bounds on heap indexes.