Thread fixes for POSIX