This fixes #162 and an unknown bug