fixed some synchronization issues

- lock was only acquired for 5 ms not for 5 seconds as intended (i guess).
- using another env variable for the initial lock time 
- removed duplicate update of the lock