various fix (thx to alexf)