Cleaned up some formatting and added some logging.