Fixed consensus code