I find the key cause of sleeplessness is stress, unsolved problems that bug you, don't work late. I find whether I drink 20 cups of coffee or none makes no difference at all, coffee or tea only works for a couple of hours. My advice would be just keep drinking the coffee, but stop in the afternoon. Coffee's much better than alcohol. Ear plugs help tremendously to give a sense of being detached, in another world...zzzzzzzzzzz I find alcohol doesn't give you a feeling of having rested. What about having a bit of a snooze at the desk, I mean just a couple of seconds stuff, where you nod off, find that helps. You might need a hobby....could be anything riding a bike, something that isn't work or your private life. I play in a band so I might spend an hour or 4 simply playing scales on the guitar, I can tell you if you're playing scales all evening your mind will be completely "void" a bit like those brain washing machines from 1960's movies.