Fixes some leaks.