Fixes #3314, #3331: Various minor fixes.