Got rid of some non-portable and not thread safe functions.