Added max threads limit