Fix diverse code quality flaws found by SQ