Code cleanup; Migration to .NET 4