lots of bug fix O.o