Order-aware patch implementation

Takes order of changes into account.