Fixes an out-of-bounds exception.