- Some minor optimization
- Make sure the data is in correct sorted order.