Fix bugs #28 and #29