NEXUS-6182: Proper syncing of critical places

Removed bad synchronized modifiers from method, properly
synced the critical place with a static lock object (that
will assure it is properly synced even in parallel builds).
Added some javadoc explaining stuff.