As I dealt with the front focus issue with my K-5 under certain conditions, I found that photo restoration type software works using deconvolution techniques. One popular plugin is Focus Magic, that improved images well. There are many more including DeblurMyImage (Here is the link:
Image Deblurring - Description - Advanced Photo Tools), which I use. The more precise one knows the point spread function (PSF), the better the restoration. DeblurMyImage allows one to enter a PSF. It looks like that sneek peak of photoshop uses an algorithm to create the PSF. There are two types of blur; out of focus and movement blur. Out of focus is the tough one to correct, because every lens has a slightly different blur. Ultimately, these programs may improve an image, but never totally fix it. In addition, when there is a combination of out of focus bokeh, and sharp parts in the photo, the correction needs to be applied only to the sections that were supposed to be sharp. This takes quite a bit of extra effort.