Fixed few bugs after moving out the_repo.
Refactored patcher