Merged the TUI bug fixes with the newer code on dev for !A testing.