Improve redraw when chaging tabs.
Add debug messages.
Move the append operation to the main event loop.