Rework repository selection mechanism

__Estimate:__ M
***