Add match expressions, terminate expressions with end, fix bugs