Merging changes from y_branch2

See commits for more details.