Merged Staffans changes