Change genetic algorithm implementation. Several fixes.