Make max number of threads configurable