Ken,
  Done, see comments in the diff above where I explain most of the changes.