Fix and cleanups for issue #7 and issue #6.