Convert to .NET 3.5

Converts target framework to .NET 3.5, with minor code changes to
support conversion.