added timeouts on waiting for lock