C# skeleton - courtesy of Kim Honkaniemi