Move Mode out of MainActivity.

This helps a bit with #23, and we can move some more code from MainActivity to
Mode. See the TODO comments in MainActivity for details.