Added tui, tuitest, main and some fixes on mastercontrol