More work on pattern matching