Miscelaneous fixes
Borrowed libc functions