Reorganized code to react on keyboard events in separate thread instead
in the main program loop.
Network interface recovery.
Cleanups.