(this should change modes correctly and address all the failed hunks in the previous porting attempt)