I'm not to 4.0 yet but I'm much closer than I was a year ago, or even 6 months ago. For me the only real secret was taking lessons regularly, once a week, and then just playing frequently (3-5 times a week).
The lessons were important because I had issues (especially on the forehand) that just weren't going to get better without outside help, and not just a time or two but I needed that consistent feedback and instruction, as bad habits die very hard most of the time, and honestly I wasn't acutely aware of exactly *why* what I was doing wasn't working or even exactly *what* I was doing wrong in certain situations. I'm sure it's possible for some very self-motivated people to get some help in other ways like posting videos and getting feedback on the internet, but I'm not optimistic that would have worked for me at all.
The hitting was also essential to work on those changes that I was implementing from the lessons, and also just because there is no substitute for court time as one tries to improve. I think 'just hitting' 100% of the time is probably not ideal, but I have no problem with doing that some of the time. Drills, practice sets, etc. can also be very useful.
So for me it's not that complicated. 1) Take lessons 2) play alot. If you do those 2 things I think you are very likely to keep improving.