Refactored the code into different files.