Adding mode infrastructure (still incomplete)