changed the static singleton access
better locking
cleanup and better checking of things