Selection improvements, code cleanup.