Add better logging for errors