Refactoring

I did a bit of refactoring of these functions to 
1. reduce code redundancy
2. improve performance
3. fix possible memory leak (IDisposables not within "using" block)
4. feature add (allowing for SQL & Perf counters to be sent at the same time).

There were quite a few lines with just whitespace, so it looks like a lot more has changed.