More refactoring and added scroll to terminal