misc fixes

See commit's for individual fixes.