After much research I figured out the underlying problem, and the fix for it. The underlying problem is magnesium deficiency. As a software developer I am using my brain more intensely than most people. This is the stress the doctors are talking about. Stress depletes magnesium. The cells in our body depend on two essential minerals for normal function: Calcium and magnesium. Cells go into ON state when calcium goes in, and OFF state when calcium goes out. Calcium doesn't go out on its own: magnesium has to go in and displace the calcium. When you are low on magnesium, cells can't go into OFF state. When that happens your muscles become stiff and you need massages, and your brain can't turn off and you can't sleep. The solution is magnesium supplements. This fixed my muscle stiffness issues and my sleep issues. A special compound of magnesium called magnesium l-threonate is especially helpful for sleep because it can penetrate the "blood brain barrier".
Scientific sources for this are hard to come by. I had to piece together all this from multiple sources. Here are some: https://www.westonaprice.org/health-topics/abcs-of-nutrition... http://www.drsinatra.com/benefits-of-magnesium-supplements-f... http://paleoforwomen.com/soul-crushing-stress-and-the-miracl...