Integrated changes from ChrisCode.