Compilation fixes for threaded Perls.
Test fixes for threaded Perls.