Not sure I understand the second 40mm part of you statement but .12 off on x and y could be under extruding or insufficient outline and infill overlap .. On my machine the only thing I can really alter accurately is Z so I take what I get with x and y since there is no mechanical or firmware means to fix them.. I typically us a 2 walled cube to check Z and a single layer model to check Extrusion Multiplier.. No spaces between threads. Also can check thinkness to verify Z. After typing that I reread your post I guess you have something loose or filament that is really fluctuating in diameter or and extruder problem.. but those are guesses