Fix up twit.php; massive reorganization of code