Fixes for several ways that the previous commit was badly broken