Cleanup output writing config for CP algs. Also properly sort the branches by output and not input.
/cc @ravinab @krumnack @bleban @jedebevc