The use of electronics/ computer/ tv/ phone, etcetera can negatively impact one's ability to fall asleep, if used too close to one's bedtime.
This is major for me. I do not have much screen time in the evenings. Even with f.lux, I find that the things that I do online tend to stimulate my brain and wake me up.
I am very sensitive to light, though, so it goes further than just screen time. We live off-grid and have very dim lights in the evening, usually just a single Ryobi lantern hanging in the room and light from the TV if we watch a show with dinner.
Before we moved off-grid, I often stayed awake half the night, e.g., usually until 2-3 am. I would not be able to sleep for an hour or more after going to bed, so I would just stay up until I was exhausted--and sometimes, that did not help, either; I'd still have trouble sleeping.
Once we moved off-grid, and the lights were always dim in the evening, I stopped having trouble going to sleep--like, from the very first day, I started falling asleep almost immediately when I went to bed. I'd recommend anyone who's having trouble sleeping to at least give it a try. It's even cheaper than free, too, since it reduces electricity usage in the evenings.
I do have to limit my caffeine intake as well. I can only have a certain amount, and I have to have it no later than early afternoon, or it will affect my sleep. I often go completely caffeine free for long periods, though I'm in a caffeine cycle right now.
That said, even when I'm doing everything right, I have weird sleep patterns. I don't seem to need 8 hours sleep every night. I find that something more like 7.5 hours to be optimal, and I will often wake up on my own, without an alarm, after that amount of time has passed. Sometimes, I will go several days, or even a week, only getting 5-6 hours of sleep per night because I will wake very early and be unable to go back to sleep--sometimes melatonin helps, sometimes not. Other times, I will be able to go back to sleep, which will cause me to sleep late for a number of days.