Added amortized analysis.