Fix #309 and #69