rewrote up to the pattern type section.