several bug corrections