Update libraries.py to use env.safe_ functions.