lb: fixed synchronization bug
lb: some code cleanup and possible synchronization bug