Reorganized main.c, added display update thread.