Rewrite raw memcard threading code. Fixes issue 7484.