Code format & cleanup
added locks to prevent collisions.
updated Javadoc
Updated Javadoc, small api fix.