refactor lock mechanism: outside of tx when appropriate & more
synchronized