Cleanup pattern building function
Merge pull request #73 from hr0nix/pattern-refactoring

Cleanup pattern building function