wrong function type declarations, and wrong argument type declarations.
Submitted by: John Birrel(L?) changes for threadsafe operations