More work on making my extension's code less "spaghetti"
According to asherkin, it's "spaghetti".