Remove unused patterns.
Add unittests.