Fixing some things that weren't thread safe.
More import / formatting cleanup.
Merge pull request #1 from StevenLawson/master

Am I doing this right...?