Implement Builder pattern, improve performances

Implement Builder pattern, to improve pattern compilation performance.
Fix and add unit tests
Fix issue #4