Fix assorted bugs with untested code from before