Added logging for troubleshooting.