fixed issues #64, #79 and #80