Fixes  for PR based on suggestions from @timgraham.