Fix errors and typo, thanks to @zebuline and @brunobord