Fixed bug with restart file - added flush
Added zero size check to vaild image
Added valid image check to defocus