Applied pthread fix by Paul Lieverse