Fixed background nullpointer issues when switching terminals