Character of the structural and magnetic phase transitions in the parent and electron-doped BaFe2As2 compounds