fixup some logic and error messages