Fix: control of tokyocabinet optimization through env variables

First change: makes sure that threshold is correctly set
second:       threshold = 100 means "no optimization at all", completely skip the optimization process in such case