Fix bug #29 and Bug #33