Changed the tree_file_next protocol to simlify.
Tidied up the edge cases for hapgen.
Replaced the haplotype generation code with C.