Refactored GUI code and added autoscroll feature