Some fixes thanks to Nicolas Ochem