Fixed bugs #35 and #29.