Fixed a lot of bug