Fix memory issue by using limited amount of threads