fix 1 bug and clean up some bugs