Add a better implementation for thread limits.