Fix lots of bug