fixed some bugs and cleaned some stuffs