PER-11: backported some changes from dev