A few fixes, improvements and compatibility from .NET 2.0