several improvements/bug corrections