add set branch file and some slight refactoring and commenting