Backport http://pcsxr.codeplex.com/SourceControl/changeset/93284