Fix issue #18 and #22.