rebase

-cleanup
-move some things into common