Fix #166 and #208