Start of splitting into modular code for ease of maintainance.