Minimize synchronized blocks

This is a simple, obviously-correct improvement of scalability: we
reduce the sice of the synchronized sections such that they only cover
the datastore interaction.

Change-Id: I1c78804e6aed22aac73f67e9c5de43ff465c7836
Signed-off-by: Robert Varga <rovarga@cisco.com>