fix issues found by better testing