Fixed bug in rebase which resulted in a bad state
Fixed bug in remove and trim related to reverting