Lots of bug fixed