Use a switch instead of an array of callbacks.

Suggested by mpi@.