Merging changes from CG & PW made directly.