Almost finish the backend integration of pattern matching