many fixes, see diff