Adding data locks to prevent exceptions in multi-threading scenarios.