I apologize for jumping in. Mac, you could not have stated it better. Every student that achieves the level of where they can begin to "improv" must first run their drills as a computer runs a macro. If you do not mind my adding to your illustrations what I share with my students... music is a language. The more command you have of the language; the better prepared you will be to express yourself with precise articulation.

And I love to use Jazz to prove that melodies are birthed by resolving incorrectly landed notes. That is how we can those funky "b5", "b5b9#11" chords after all.

To the one who posted the question. I try to get my students to memorize the movements as referenced... then forget them. That is to say, don't fall into the rut of running the same string of notes together that comprised the scale each time you play.

Learn everything to build your tool box. Then, the artistry comes from when you know which tool to use and where as you are playing/performing. I heard a quote that Miles told Herbie Hancock where he encouraged Hancock to play every concert as if it were a rehearsal. That is, we normally stretch ourselves during rehearsals and pull back during the performance to what is safe. Miles wanted that musical stretch to be on during the performance. And when you get to the place where this all begins to make sense it is a blast to let loose with some good players and hear what develops.