fix minor bugs in mode functions