It kind of works but, again, the logic in the main loop is pretty twisted.  The next commit should hopefully tighten it up significantly.