avoid deep equality when comparing functions
minor changes to infer test
efficient version of gibbs, minor refactoring