bug fixes, better error messages, logging