Updated NuGet references. Added more error checks