Added nuget packaging and refactored to DRY up the code.