Added PC locking scheme to prevent off-by-1 errors.