Reworked the mincut problem since my inplace solution failed