Added pointer restoring on out-of-bounds errors