Improve the code organizations and fix the scroll to top functionality