Fix issue #5 and #12