Working code.

  This code successfully handles the cases that used to be handled,
 and the new case - if/when this code is ported we'll be able to
 update #186.