Updated pattern builder with more easy to read, anf better performing implementations.