Rewrote most of the existing code using a more object-oriented model. Also added support for specifying the part of the pattern to use for comparison.