Add guards before writing to out pointers
Allow adding arrays of modules
Refactor thread pool code out of main and into the library