Add better logging of errors