bug fixes and error messages