lots of fixes. sorry for lack of details