sf: Fix memory leaks