I have no idea if this will be of any help at all but...
I was recently using my Bernina 820 to simply stitch a basic zigzag around appliqué shapes. It began giving me an
Top thread is broken error after every seven stitches. I re-threaded, cleaned, etc. just like you. It drove me crazy for a full day. Then I remembered that there might be a setting in the basic set-up program of the machine about broken thread alerts. I found that, shut it off, and the problem was solved.
I realize my problem was not with embroidery and on a different model, but when you said "after every forty stitches" it reminded me of how my problem was after exactly every seven stitches. Good luck!! I hope you find the answer quickly, I know how frustrating it can be!!!