Cherry pick unmerged changes from develop

This pull request is against master, in order to update it with the latest code changes from develop. After this change the only remaining unmerged changes are documentation changes, which includes the literate tests extracted from the documentation. I left them out because I don't know why they were never merged to release in subversion.