Fix bug where remote rewrite