tried to remove some space leaks