Fix issue #77 and issue #79

Fix issue #77 and issue #79