Move const to file where it is used
Make worker count configurable
Split up function