Fixed a number of issues found in code review.