merging Peter's fixes