Wait handling redone. Seems to work except for one bug so far:  doesn't output to test.