Transport theory of ferromagnetic nanograins and dephasing in qubits with environmental resonancesTrack