Bug fixes and error handling improvements.