Added more logging for easier debugging.