Fix reproducibility bug.
Make debug mode configurable.