Refactored main program; fixed other issues.

Severely refactored the code from the long, unwieldy main program it grew into. Instead of everything being doen in main, the function now makes a series of calls to smaller functions instead. Also, through the help of valgrind, removed memory leaks from a few places in the code. Made sure to actually end the receiving pthread through the use of a shared flag as well, instead of trying to use pthread_kill, which did not have the behavior I initially thought it did. Also updated client.c to reflect the changes in ncurses_client.c; it is now simply a version of the ncurses_client without the ncurses. This was used to simplify some valgrind testing.