small improvements to the csharp version so it can be run on mono