Expand thread.c - replace pthread with thread.c wrappers