Fix #16 and fix #21