Rebase staging

this is just soren's staging patch rebased against master