fix bug #33 and some other changes