Rewrite basically everything to use modes.