Fixed #650 and #651