Broken some code up for module generalization.