Moved a lot of pattern matching code to a base class and added markdown tag for linking to other articles.