Reduce number of regex calls
Extract repo validation logic
Simplify token resolution logic
Extract token validation logic
DRY up error dialog logic