Removed trigger_error calls with appropriate exceptions.