Fix of a few bug + more explicit error messages