Add pattern system
Address merge conflict on pattern.php