A patial C# port of VB.NET project