Fix NULL returns.
Fix consrt/destr leaks.
Fix trailing space.
Formatting, clarification.
From Cristina: coverity fixes.