Error message and handling improvements