paste mode, some reordering and fixes