Incorporated fixes to issues with examples identified by Rickard Bellgrim.