Implemented the remaining cases in betaReduce().