Betti number bug fix