Clean up clang warning -Wparentheses-quality

Remove extraneous parentheses in equality comparison.
Clean up clang warning -Wdangling-else

Add some explicit braces to avoid dangling elses.