Reorganized for functions to be at top and cleaned up threshold determination.
Allow users to specify the quantile for threshold determination
Updated variable name for override quantile
Add feature to write thresholds to a file