Minor refactoring
Moved regex compilation