small progress toward #91

Hope this doesn't introduce too many bugs.