Fixed pattern matching issues