Fix safe region functionality (thanks ChaosWormz).