Fix 'if' block missing braces and const correctness