fix for #3 and other fixes