moved vector construction in tree construction. Both for input and output.