Fixed #767
Fixed #192, progress on #769