Fixed a few obvious errors pointed out by the static analyzer.