Corrects bad revert #62 to initial correct merge #52

Fixes issue #45 
All credit for the fixes to #45 goes to @gdevenyi 
My apologies for the cluttered log but I opted not to rewrite or clobber history