Added more return values and errors.