Light improvements. Less debug output. Subject to emails. Protection from concurency - locking.

Signed-off-by: Alexey Korolev <akorolex@gmail.com>