A 20mm lens has a hyperfocal distance of less than 10m at f/1.4 and less than 5m at f/2.8: unless you are focusing on something very near minor inaccuracy of focusing should not have any easily detectable effect. So, if you are getting obviously out of focus images there must be a major problem.
Is the problem mostly in focus images and occasional out of focus images, or consistently out of focus images? All AF systems have occasional bloopers, where the lens elements just do not go where the camera intended them to, which can be reduced by giving the system more time to work: pressing the shutter slowly or repeated shutter button half-press/AF-on button.