Added regex config and minor refactoring