Version with most errors fixed