Improved pattern matching.