Cleaned up the 'rew' function so that flags and local/remote options are easier to understand.