Many bug fixs