Fix #99 and partially fix #103