source as-is from codeplex branch 4.2.x