Cleaned up some error handling duplication