Fixes for OSX and refactor of Urwid code