Rewrote Pattern, PatternElem and NGram classes. Moved continuation counters classes into legacy package.