Merged from CellProfiler and made tests run.

Merged CellProfiler/CellProfiler@7f5ad9a78f3dc826f6922b85b69151ef30a6246f
Call pthread_join properly

See comment: https://github.com/CellProfiler/CellProfiler/commit/63203e75d284a738d67e22d7c29a8846432002ad#commitcomment-5344583
Call printf properly to avoid warning
Don't expose internal functions

Continue to use them for testing.