Replace some `if/elif/elif/...` constructs with dict lookup