First pass on better error handling
Second pass on better error handling