Fixing memleaks.