Cleaned up the application API, and added more logging.
Moved unsafe logging/log level to global library state.
Minor cleanups.
Add a ton of logging.