Refactored fitness/semantics in generate_trees.py.