Fix for NullReferenceException issue

Refactored the method a bit to tidy it up while resolving this.

Fixes issue noted in https://github.com/MindscapeHQ/raygun4net/issues/63