Bugfixes and XTerm support