Moved code from the main code to the configure code for testability.