add a JOIN_THREADS_BEFORE_FORK preprocessor flag to help debug locking problems
Fix two clang warnings