Fix #208, #203 and #217