cloned from codeplex