Code Refactoring - NOT TESTED

These changes have not been tested, and should not be considered as
stable or valid