Improve exception handling and nuget package restore

Closes #279