Merge pull request #1 from tomka/prevent-threshold-overflow
Prevent potential overflow of channel specific thesholds
Note: this is a quick bug fix, but it introduces technical debt: the range check is repeated, violating the DRY principle (i.e. bloating the code and making bug fixes prone to cover only *part* of the copy-edited versions). However, subsequent pull requests can fix this.