small error handling improvements