X-ray diffraction scans consist of series of counts; these numbers obey Poisson distributions with varying expected values. These scans are often smoothed and the K alpha(2) component is removed. This article proposes a framework in which both issues are treated. Penalized likelihood estimation is used to smooth the data. The penalty combines the Poisson log-likelihood and a measure for roughness based on ideas from generalized linear models. To remove the K alpha doublet the model is extended using the composite link model. As a result the data are decomposed into two smooth components: a K alpha(1) and a K alpha(2) part. For both smoothing and K alpha(2) removal, the weight of the applied penalty is optimized automatically. The proposed methods are applied to experimental data and compared with the Savitzky-Golay algorithm for smoothing and the Rachinger method for K alpha(2) stripping. The new method shows better results with less local distortion. Freely available software in MATLAB and R has been developed.