Delayed curses initialization to prevent corruption of error messages printed to stdout. Moved tcp connection initialization to happen before curses init for the same reason.