Major improvements and fixes to Gibbs sampling.