fix for #20, #31 and some other little things