Optomize and refactor

Refactor stub optimization code for sections into several functions.
Refactor references to "placeholder" to be "marker".