minor changes to tdem writeup and code (still buggy!)