Fixes for some code that is as-yet untested