refactor: improves thread-safety using ReaderWriterLockSlim.