some bugs, some fixes