[#60634864] Cleaned up the code. Ease memory use a little. Fixed all analyzer warnings.