Many bug corrections