pb: refactoring to better handling repository initialization