Remove all the ugly pattern matching code.