Big remake : respect selections, restore viewport position, corret bugs