some fixes to bugs