A few bug fixes based on static memory analyzers (thanks, Dennis Luehring)