Various improvements regarding the porting to pairs.
Changed when and unless macros.