fix unsafe code in libraries