Fix issue #5 and others found during testing.