add pair generator and some misc improvements