Fix repository update issue

When updating repositories, properly purgue referenced
repos that are not used anymore.