fixed removing repositories, added some locking