Replace thd3 with pattern-matching
Move ljustify to where it's used
Replace MaybeErr with Either