Fix #244 and #265