Made LockService thread safe

The LockService should not be used in the threaded framework but getting it working may help with migration. The scoped_lock was removed since it was being updated each call and therefore was not safe if multiple modules are running concurrently. Instead we directly call ‘lock()’ and ‘unlock()’.