Implementation of patterns

Use patterns and remove many handwritten messages.