More cosmetic fixes identified through static analysis

- Simplify if/return statement combinations

- Simplify boolean expressions

- Remove redundant variables