Minor code reorganization

Removed a couple global variables and moved curses functions into a
separate module.