Pattern automation simplified and refactored.