Working on xbmain. Need to finish the main control thread and ui thread
plus review.