Make main process join first thread.
Merged with Neil's edits.