Analyze Fixes

Fixes the issues that "Analyze Build" uncovered, including a dead store and three memory leaks.