Fixes potential leaks