Fix few obscure fork-related bugs