fix some bugs lingering from commit 238706b5f6e610cfab09a6af36a307e20af29cb7