Rework Modality to allow definition of modes in config/modes.rb

This should close #40. There's a lot in here, but the commits are small enough that you should be able to follow it through pretty easily - the tests should all pass at every commit too.