Refactor and autoscroll