Integrated some of Sadie's modifications into integration branch.