Seemingly working version of entire robustified implementation