Terminal: Several performance improvements