Fix seriously horked data refresh logic

Should fix #19.  r? @rfk
May as well keep this test of `needs_refresh` as well as the new code.