Fix semantic check issues found by the instructors

Can be combined with the surrounding `match`.