Fix #326 and fix #229