fixed #34, progress on #41, improved error messages