fix issue #16 more fixes from review