Dalton's mistake came from the fact that he refused to acknowledge the existence of molecules. Amedeo Avogadro said that equal volumes of gases contain equal numbers of particles, and the particles must be molecules. Molecules can be a combination of atoms of different elements, a combination of atoms of the same element, or just one atom of an element. Some elements naturally exist as diatomic molecules. These are oxygen, hydrogen, nitrogen, fluorine, chlorine, bromine, and iodine.
Most elements exist as monatomic molecules, however.
With these new assumptions we notice that Gay-Lussac's observations fit nicely with Dalton's theories. Two parts of hydrogen would contain four hydrogen atoms. One part of oxygen would contain two oxygen atoms. The number of atoms we started with is the number of atoms that are present at the end of the reaction. Hence, we have finally removed the thorn from Dalton's side.