Use variables to increase efficiency
In this commit, efficiency has been increased greatly in order to reduce
the number of lines of code in the plugin. This was done by turning the
spawning operation into a variable, thus eliminating the need to run
several operations separate from each other, and repeated manually.