Merge with JohnDougal's code.