Moved scroll to first/last line code to their own function.