A lot of threshold fine tuning, error checking, and more failure handling