Improved collapse logic. Added to-top scrolling for navigation.