fix various issues found by sanity scripts