Fix many many bugs