Fix memory/proccess leaks