Cleaned up debug functions and added NLog logging.