fixes and cleanups for bugs 783499 and 808370