Fix #168 and #219