Dependency update and cleanup.
Refactored safe code to help prevent crashes.