Problem with type checking patterns, fixes #321