Fix various bugs, target .NET 3.5.