Fixed fd leaks (spotted by Cihan Altinay).