Better implementation of #128 fix.