added Potts models features and major bug fixes to bean functions