a few more changes after checking internal consistency.