cleanup main and transition code.