some fixes and  improvements