Added missing braces for if statements, also fixes #169.