Cleanup the fix for #143 and #157.  This is less code and less special
cases, hopefully it doesn't introduce more defects in the process.