Add Gamma.
Fix non-deterministic behavior issue.
Various small things.