Fix potential NullReferenceExceptions.
Fix .NET 4.5 configuration.