Much simpler fix for #25 still passes tests.