Refactor in Std_ded

* Merged from Ilia's changes and resolved a few conflicts.
* Handled nearly all `np.where` statements in Std_ded. One is still troubling. I'm asking the Numba team about it today