Purge unsafe code, except where necessary to call libc functions