Implement better logging; fixes #43