Fixing memoryleaks.