Added scroll-to-selection, some fixes for state restoration.