Remove unneeded match expressions
Make aggregate functions return options