Cleaning up Restrict: Some initial refactoring to remove repeated code.