I drank coffee for several years (around 4 cups a day, not later than 4pm) and suffered from insomnia and didn’t know the origin. Since I stopped caffeine intake, my insomnia is basically gone and I feel a lot more functional because of better sleep.
So my impression (yeah I have to admit it’s a study of size 1) is rather that caffeine is more dangerous than I thought.