Replace some big ifs with selects, at the request of @MMeent