factor out mode parsing
Merge branch 'master' of github.com:rfw/merc