Disclosed is an apparatus for treating a respiratory disorder, configured to compute a measure of typical recent ventilation such that a rate of adjustment of the measure of typical recent ventilation is reduced as a measure of recent uncompensated leak increases. Also disclosed is an apparatus for treating a respiratory disorder, configured to compute a target ventilation from a product of a measure of typical recent ventilation and a target fraction, wherein the target fraction is dependent on the recent pressure support.