threshold bug fix, unit bug fix
Merge pull request #307 from jpecht/master

threshold bug fix, unit bug fix