changed the static singleton access
better locking
cleanup and better checking of things
Merge pull request #1 from col-b/master

this is what we want!