changed k-factor calculation, now it is faster and correct
trying to get branches back together