Refactor, reduce memory use, improve scroll to bottom behavior