Fix #19, fix #20, fix #21