Fixed threadding errors from issue #37
Code formatting fix ups
Merge remote-tracking branch 'cyberjacob/master' into working. Fixes #37