adding some unmerged changes from pyramid-branch