Too much caffeine will definitely do weird things to your sleep patterns.
Cut down to just one or two cups a day at most (none at all would be best), and none at all after 4pm. Wait at least a week to adjust to the different sleep schedule that will come from taking in less caffeine.
If the problem continues, see a doctor. HN is not qualified to give medical advice, except medical advice of the form "Go see a doctor."