various bug corrections