More robust fix for Nette compatibility