fixes and error handling