Fix Issue #30 and issue #31