Fixed possible deadlock in threshold value computation + more complete parameter checking.